/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelAgenda.java
 *
 * Created on 26-oct-2011, 14:38:08
 */
package co.edu.eam.clinica.vista.gui.consulta;

import co.edu.eam.clinica.vista.controladores.consulta.controladorConsultaClinica;
import co.edu.eam.clinica.vista.gui.common.PanelOncologos;
import co.edu.eam.persitencia.entidades.Consulta;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;


/**
 *
 * @author Camilo Andres
 */
public  class PanelAgenda extends PanelOncologos {

    controladorConsultaClinica controlConsulta = new controladorConsultaClinica();
    /** Creates new form PanelAgenda */
    public PanelAgenda() {
        
        
      initComponents();
      
      
    }
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tablaCitas = new javax.swing.JTable();
        bVerCita = new javax.swing.JButton();
        panelDatosUser = new javax.swing.JPanel();
        dcFecha = new com.toedter.calendar.JDateChooser();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        panelDatosIn = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        tfMEdico = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        tfEspecialidad = new javax.swing.JTextField();

        tablaCitas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "id", "Fecha/Hora", "Paciente", "Documento", "EPS"
            }
        ));
        jScrollPane1.setViewportView(tablaCitas);

        bVerCita.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/torresquintero/oncologos/medico/imagenes/imagenes/24x24/vercita.png"))); // NOI18N
        bVerCita.setText("Ver Cita");
        bVerCita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bVerCitaActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/torresquintero/oncologos/medico/imagenes/imagenes/24x24/buscar-buscar-ampliar-icono-4271-32.png"))); // NOI18N
        jButton1.setText("Buscar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Fecha");

        javax.swing.GroupLayout panelDatosUserLayout = new javax.swing.GroupLayout(panelDatosUser);
        panelDatosUser.setLayout(panelDatosUserLayout);
        panelDatosUserLayout.setHorizontalGroup(
            panelDatosUserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosUserLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(dcFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelDatosUserLayout.setVerticalGroup(
            panelDatosUserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosUserLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(panelDatosUserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addComponent(dcFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jLabel2.setText("Medico");

        tfMEdico.setEditable(false);

        jLabel3.setText("Especialidad");

        tfEspecialidad.setEditable(false);

        javax.swing.GroupLayout panelDatosInLayout = new javax.swing.GroupLayout(panelDatosIn);
        panelDatosIn.setLayout(panelDatosInLayout);
        panelDatosInLayout.setHorizontalGroup(
            panelDatosInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosInLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(10, 10, 10)
                .addGroup(panelDatosInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfMEdico, javax.swing.GroupLayout.PREFERRED_SIZE, 412, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(156, 156, 156))
        );
        panelDatosInLayout.setVerticalGroup(
            panelDatosInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosInLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tfMEdico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDatosInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(tfEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelDatosUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelDatosIn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1)
                    .addComponent(bVerCita))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panelDatosUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(panelDatosIn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addComponent(bVerCita)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            // buscar la consulta por fecha
            Date fecha= dcFecha.getDate();
            
            //llenar tabla
            
            DefaultTableModel modelo = new DefaultTableModel();
            this.tablaCitas.setModel(modelo);
            
            modelo.setColumnCount(0);
            modelo.addColumn("id");
            modelo.addColumn("fecha/hora");
            modelo.addColumn("paciente");
            modelo.addColumn("documento");
            modelo.addColumn("eps");
            
            List lista =controlConsulta.listarFecha(fecha);
            modelo.setNumRows(lista.size());
            
            for (int i = 0; i < lista.size(); i++) {
                Consulta con=(Consulta) lista.get(i);
                
                modelo.setValueAt(con.getId(), i, 0);
                modelo.setValueAt(con.getFechaHora(), i, 1);
                modelo.setValueAt(con.getPaciente().getNombre(), i, 2);
                modelo.setValueAt(con.getPaciente().getDocumento(), i, 3);
                modelo.setValueAt(con.getPaciente().getEps().getNombre(), i, 4);
                
                this.tablaCitas.setModel(modelo);
            }
            
            
        } catch (Exception ex) {
            Logger.getLogger(PanelAgenda.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void bVerCitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bVerCitaActionPerformed
        
       
       


        
    }//GEN-LAST:event_bVerCitaActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bVerCita;
    private com.toedter.calendar.JDateChooser dcFecha;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel panelDatosIn;
    private javax.swing.JPanel panelDatosUser;
    private javax.swing.JTable tablaCitas;
    private javax.swing.JTextField tfEspecialidad;
    private javax.swing.JTextField tfMEdico;
    // End of variables declaration//GEN-END:variables
	
}
